setClass("PCAReducer",contains="vPCAReducer",
		representation(
				.center="logical",
				.scale.="logical"
				),
		prototype=prototype(
				.description="PCA Reducer Class",
				.center=TRUE,
				.scale.=FALSE
				)
		)

#methods

setMethod("initialize",
		signature="PCAReducer",
		function(.Object,dimChooser,center=TRUE,scale.=FALSE,...){
			.Object <-callNextMethod(.Object,dimChooser,...);
			.Object@.center <- center;
			.Object@.scale. <- scale.;
			return(.Object)
		})


setMethod("reduce",
		signature="PCAReducer",
		definition=function(.Object,inputSet,...){
			tmpResult <-prcomp(as.matrix(inputSet),retx=TRUE,center=.Object@.center,scale.=.Object@.scale.)
			.Object@.eigenValues	<- (tmpResult$sdev)^2;
			.Object@.eigenVectors	<-tmpResult$rotation;
			.Object@.rotatedSet		<-tmpResult$x;
			.Object@.tmpData		<-as.matrix(inputSet)
			
			dim <-chooseBest(.Object@.dimChooser,.Object)
			
			.Object@.rotatedSet <- (.Object@.rotatedSet)[,1:dim,drop=FALSE]
			.Object@.tmpData <- matrix()
			.Object@.resEnv$savedSet <- .Object@.rotatedSet 
			return(.Object@.rotatedSet)
			
		})
